// Project name:JavaRedis
// Creator:muhong
// Date time:2022/12/10,9:42 下午
// Name:DefaultChannelHandlerContext

package org.gmh.channel;

import org.gmh.channel.handler.ChannelInboundHandler;
import org.gmh.channel.handler.ChannelOutboundHandler;
import org.gmh.util.concurrent.EventExecutor;

public class DefaultChannelHandlerContext extends AbstractChannelHandlerContext {

    private final ChannelHandler channelHandler;

    DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor,
                                 String name,
                                 ChannelHandler channelHandler) {
        super(pipeline, executor, name, isInbound(channelHandler), isOutbound(channelHandler));
        this.channelHandler = channelHandler;
    }

    @Override
    public ChannelHandler handler() {
        return this.channelHandler;
    }

    private static boolean isInbound(ChannelHandler channelHandler) {
        return channelHandler instanceof ChannelInboundHandler;
    }

    private static boolean isOutbound(ChannelHandler channelHandler) {
        return channelHandler instanceof ChannelOutboundHandler;
    }

    @Override
    public ChannelFuture close() {
        return null;
    }
}
